package simplescenegraph.math;
public class Vector4f {
	
	float x, y, z, w;
	
	public Vector4f() {
		x=0;y=0;z=0;w=0;
	}
	
	public Vector4f(float x, float y, float z, float w) {
		this.x=x;this.y=y;this.z=z;this.w=w;
	}
	
	public Vector4f(Vector4f arg0) {
		this(arg0.x,arg0.y,arg0.z,arg0.w);
	}
	
	public Vector4f(Vector4f p0, Vector4f p1) {
		this(p1.x-p0.x, p1.y-p0.y, p1.z-p0.z,p1.w-p0.w);
	}
	
	public Vector4f(Vector3f arg0, float w) {
		this(arg0.x,arg0.y,arg0.z, w);
	}	
	
	public void add(Vector4f arg0) {
		this.x+=arg0.x;this.y+=arg0.y;this.z+=arg0.z;this.w+=arg0.w;
	}
	
	public void subtract(Vector4f arg0) {
		this.x-=arg0.x;this.y-=arg0.y;this.z-=arg0.z;this.w-=arg0.w;
	}
	
	public void multiply(float a) {
		this.x*=a;this.y*=a;this.z*=a;this.w*=a;
	}
	
	public void divide(float a) {
		this.x/=a;this.y/=a;this.z/=a;this.z/=a;
	}
	
	public float dotProduct(Vector4f arg0) {
		return x*arg0.x + y*arg0.y + z*arg0.z + w*arg0.w;
	}
	
	public Vector4f projection(Vector4f q) {
		Vector4f projQP = new Vector4f(q);
		projQP.multiply((dotProduct(q) / q.squaredLength()));
		return projQP;
	}
	
	public float squaredLength() {
		return x*x + y*y + z*z + w*w;
	}
	
	public float length() {
		return (float) Math.sqrt(x*x + y*y + z*z + w*w);
	}
	
	public void normalize() {
		float l0 = length();
		if (l0 > 0) {
		x /= l0;
		y /= l0;
		z /= l0;
		w /= l0;
		}
	}
	
	public boolean equals(Object obj0) {
		Vector4f v0 = (Vector4f) obj0;
		return x == v0.x && y == v0.y && z == v0.z && w == v0.w;
	}
	
	public String toString() {
		return "|" + x + "|\n|" + y + "|\n|" + z + "|\n|" + w + '|'; 
	}
	
	public float[] toFloatArray() {
		return new float[] { x, y, z, w };
	}
	
}
 
